<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>更新数据</title>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript">

        $(function () {
            setInterval(function () {
                let $mytable = $("#mytable");
                var rssilist = [];
                $.ajax({
                    type: "get",
                    async: false,
                    url: "getxy",
                    data: {
                        status: "RSSI"
                    },
                    dataType: "json",
                    success: function (data) {
                        for (var i = 0; i < data.length; i++) {
                            rssilist.push({
                                number: data[i].number,
                                frequency: data[i].frequency,
                                ap1Mac: data[i].AP1MAC,
                                ap1Rssi: data[i].AP1RSSI,
                                ap2Mac: data[i].AP2MAC,
                                ap2Rssi: data[i].AP2RSSI,
                                ap3Mac: data[i].AP3MAC,
                                ap3Rssi: data[i].AP3RSSI
                            });
                        }
                    },

                    error: function () {
                        alert("获取数据失败");
                    }
                });
                $mytable.empty();

                var title = ["编号","频率","AP1MAC","AP1RSSI","AP2MAC","AP2RSSI","AP3MAC","AP3RSSI"];
                var $tr = $("<tr></tr>");

                for (let i = 0; i < 8; i++) {
                    var $th = $("<th></th>");
                    $th.text(title[i]);
                    $tr.append($th);
                }
                $mytable.append($tr);
                // $mytable.append("<tr><th>编号</th> <th>频率</th> <th>AP1MAC</th> <th>AP1RSSI</th> <th>AP2MAC</th> <th>AP2RSSI</th> <th>AP3MAC</th> <th>AP3RSSI</th> </tr>");
                for (var i = 0; i < rssilist.length; i++) {
                    $mytable.append("<tr>"
                        + "<td>" + rssilist[i].number + "</td>"
                        + "<td>" + rssilist[i].frequency + "</td>"
                        + "<td>" + rssilist[i].ap1Mac + "</td>"
                        + "<td>" + rssilist[i].ap1Rssi + "</td>"
                        + "<td>" + rssilist[i].ap2Mac + "</td>"
                        + "<td>" + rssilist[i].ap2Rssi + "</td>"
                        + "<td>" + rssilist[i].ap3Mac + "</td>"
                        + "<td>" + rssilist[i].ap3Rssi + "</td>"
                        + "</tr>")
                }
            }, 1000)
        });
    </script>
</head>
<body>
<div style="float: left;width: 10%">
    <a href="http://120.27.237.68:8080/web/newdata.html">数据库内容2</a><br>
    <a href="http://120.27.237.68:8080/web/location.html">定位界面1</a><br>
    <a href="http://120.27.237.68:8080/web/location2.html">定位界面2</a><br>
    <a href="http://120.27.237.68:8080/web/TD2.html">热力图1</a><br/>
    <a href="http://120.27.237.68:8080/web/TD.html">热力图2</a><br/>
</div>

<div style="float: right;width: 90%">
    <table id="mytable" align="center" width="800" border="1" cellpadding="0">
    </table>
</div>


</table>
</body>
</html>